import React, {useContext} from 'react'
import { appContext, appSetStateContext } from '../AppState'
import { useAddToCart } from './AddToCart'
// 创建接口
export interface RobotProps {
  id: number,
  name: string,
  email: string
}

const RobotDiscount: React.FC<RobotProps> = ({id, name, email}) => {
  const value = useContext(appContext)
  const addToCart = useAddToCart()
  return (
    <li>
      <img alt="robot" src={`https://robohash.org/${id}`}></img>
      <h3>打折商品</h3>
      <h1>{name}</h1>
      <p>{email}</p>
      <h1>{value.userType}</h1>
      <button onClick={() => addToCart(id, name)}>加入购物车</button>
    </li>


  )
}

export default RobotDiscount
